<%@ page pageEncoding="UTF-8" %>
<script src="<c:url value='/resources/js/manage.js'/>"></script>
<c:import url="../../../template/layout.jsp" charEncoding="UTF-8">
  <c:param name="title" value="权限列表"/>
  <c:param name="body">
    <script>
      $(document).ready(
              function () {
                var id = $(".id").val();
                if (id) {

                }

              });
    </script>


    <div class="content-title">权限列表
      <p>${message.msg}</p>
    </div>
    <div class="container"
         style="background-color:#DCEAF4; width:1300px; height:500px;border-radius: 0px 0px 0px 0px;">
        <c:if test="${message!=null}">
            <div class="alert alert-danger" role="alert">${message.msg}</div>
        </c:if>
      <div class="btn-group pull-right" style="margin-bottom:8px;">
        <a class="btn btn-lg btn-primary" href="${pageContext.request.contextPath}/system/permission/edit">
          <span class="glyphicon"></span> 添加权限
        </a>
      </div>
      <p></p> <div class="col-sm-5 col-sm-offset-1">
        <form id="searchForm" method="get" action="/system/permission/list"
              name="user">
            <div class="input-group">
                <input id="pageNo" name="pageNo" type="hidden" value="${pager.pageNo}"/>
                <input id="pageSize" name="pageSize" type="hidden" value="${pager.pageSize}"/>


            </div>
        </form>
    </div>

      <div class="main-content">

        <table class="table">
          <thead>
          <tr>
            <th>权限</th>
            <th>描述</th>
            <th>操作</th>
          </tr>
          </thead>
          <tbody>
          <c:forEach items="${pager.list}" var="permission">
            <%--<s:iterator value="#request.roleList" var="role">--%>
            <tr class="success">
              <td>${permission.permissionName}</td>
              <td>${permission.per_description}</td>

              <td>
                <button onclick="editPermission('<c:url value="/system/permission/getPermission?id=${permission.id}"/>')"
                        class="btn btn-primary btn-xs"
                        data-toggle="modal" data-target="#editPermission">编辑
                </button>
                &nbsp;&nbsp;
                <button class="btn btn-primary btn-xs"
                        href="javascript:void(0)" data-toggle="tooltip" title="删除"
                        onclick="if (confirm('确认要删除本记录吗？此操作将不可恢复！'))
                                location = '<c:url
                                value="/system/permission/delete?id=${permission.id}"/>';
                                return false;">删除
                </button>


              </td>
            </tr>
            <%--</s:iterator>--%>
          </c:forEach>
          </tbody>
        </table>
      </div>
        <div class="row">
            <div class="col-sm-12">
                    ${pager}
            </div>
        </div>
    </div>
    <script type="text/javascript">

      function editPermission(path) {
        $.ajax({
          url: path,
          type: 'get',
          async: true,
          dataType: 'json',
          success: function (permission) {
            /*var temp = '<input class="edit_check" type="checkbox" name="permissions" />';
             $("#edit_per").removeChild(temp);*/
$('#edit_id').val(permission.id);
            $('#edit_permissionName').val(permission.permissionName);
            $('#edit_per_description').val(permission.per_description);
          }
        });
      }


    </script>
    <%--编辑修改模态框--%>
    <div class="modal fade" id="editPermission" tabindex="-1" role="dialog">
      <div class="modal-dialog modal-lg">
        <div class="modal-content">
          <div class="modal-header">
            <button type="button" class="close" data-dismiss="modal">
              <span aria-hidden="true">&times;</span>
              <span class="sr-only">Close</span>
            </button>
            <h3 class="modal-title">编辑</h3>
          </div>
          <div class="modal-body">
            <form action="/system/permission/edit" method="POST">
              <div class="form-group">
                <label class="control-label" for="edit_permissionName">权限</label>
                <input type="text" class="form-control" id="edit_permissionName" name="permissionName"
                       required>
              </div>
              <div class="form-group">
                <label for="edit_per_description">手机</label>
                <input class="form-control" id="edit_per_description" name="per_description" required/>
              </div>
              <div class="form-group">
              <input class="form-control" type="hidden" name="id" id="edit_id"/>
                </div>
              <button class="btn btn-primary btn-lg btn-block" type="submit">
                确定
              </button>
            </form>
          </div>
        </div>
      </div>
    </div>
  </c:param>
</c:import>
